<template>
	<section>
		<!--工具条-->

		<el-row class="toolbar" style="padding-bottom: 0px;" type="flex" size='medium'>
			<el-col :span="6" >
				<!-- <el-button type="primary" @click="handleAdd" size='medium'>新增用户</el-button> -->
			</el-col>
			<el-col :span="18"  size='medium'>
				<el-form :inline="true"   style="float:right" >
						<el-form-item >
							<el-select placeholder="选择画室" v-model="forms.studioName">
								<el-option v-for="studio in studios"
										:key="studio.studioName"
										:value="studio.studioName">
								</el-option>
							</el-select>
					</el-form-item>
						<el-form-item >
						  <el-select placeholder="选择省份" v-model="forms.province">
                       <el-option v-for="province in provinceList"
                                  :key="province.province"
                                  :value="province.province"
                                  :label="province.province">
                       </el-option>
               </el-select>
					</el-form-item>
					<el-form-item >
								<el-select placeholder="选择等级" v-model="forms.grade">
												<el-option v-for="grade in gradeList"
																		:key="grade.grade"
																		:value="grade.grade"
																		:label="grade.grade">
												</el-option>
								</el-select>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" v-on:click="getUsers" size='medium'>查询</el-button>
					</el-form-item>
				</el-form>
			</el-col>
			
		</el-row>
		
		<!--列表-->
		<el-table  :data="users" highlight-current-row v-loading="listLoading" @selection-change="selsChange" border 
	:header-cell-style="{background:'#204BD6',color:'#fff'}"
		style="width: 100%;">
			<el-table-column prop="admissionTicketCode" label="准考证号"  header-align='center' >
			</el-table-column>
			<el-table-column prop="examineeName" label="姓名" width="100" header-align='center'>
			</el-table-column>
			<el-table-column prop="identificationNumber" label="身份证号"  header-align='center'>
			</el-table-column>
			<el-table-column prop="studioName" label="画室名称"  header-align='center'>
			</el-table-column>
			<el-table-column prop="province" label="生源省份"  header-align='center'>
			</el-table-column>
			<el-table-column prop="sumiao" label="素描"  header-align='center' align="center">
		<template slot="header" slot-scope="scope">
					<div>素描</div>
						<div>等级 分数</div>
					</template>
				<template slot-scope="scope">
					<span>{{score(scope.row.sumiao)}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="secai" label="色彩"  header-align='center' align="center">
				<template slot="header" slot-scope="scope">
						<div>色彩</div>
						<div>等级 分数</div>
					</template>
				<template slot-scope="scope">
					<span>{{score(scope.row.secai)}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="suxie" label="速写"  header-align='center' align="center">
				<template slot="header" slot-scope="scope">
					<div>速写</div>
						<div>等级 分数</div>
					</template>
					<template slot-scope="scope">
					<span>{{score(scope.row.suxie)}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="sheji" label="设计"  header-align='center' align="center">
				<template slot="header" slot-scope="scope">
					<div>设计</div>
						<div>等级 分数</div>
					</template>
					<template slot-scope="scope">
					<span>{{score(scope.row.sheji)}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="sortByStudio" label="画室内排名"  header-align='center'>
			</el-table-column>
			<el-table-column prop="sortByComplex" label="总排名"  header-align='center'>
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination layout="prev, pager, next" @current-change="handleCurrentChange" :page-size="20" :total="total" >
			</el-pagination>
		</el-col>
	</section>
</template>

<script>
	import {score2grade}from '../../utils/gradeA'
	import provinceCodeList from "../../utils/provinceCode";
	import gradeCodeList from "../../utils/gradeCode";
	import axios from 'axios'
	import {score_queryScore,getStudioList} from '../../api/api';
	export default {
		components:{},
		data() {
			return {
				studios:[],
				provinceList: provinceCodeList,
				gradeList:gradeCodeList,
				userModifyVisible:false,
				userAddVisible: false,//编辑界面是否显示
				forms:{
					size:10,
					current:1,
					province:'',
					studioName:'',
				},
				transRow:{},
				exampaper:[],
				users: [],
				total: 0,
				page: 1,
				listLoading: false,
				sels: [],//列表选中列
				hasCourses:[{lable:'素描'},{lable:'上海'},{lable:'浙江'}],
				hasProvinces:[{lable:'北京'},{lable:'上海'},{lable:'浙江'}],
				editLoading: false,
			}
		},
		methods: {
			score(val){
				let showcore='-'
				if (val){
					showcore=score2grade(val)+ " "+val 
				}
				return showcore
			},
			handleCurrentChange(val) {
				this.page = val;
				this.getUsers();
			},
			//获取用户列表
			getUsers() {
				this.listLoading = true;
				score_queryScore(this.forms).then((res) => {
					console.log(res)
					this.total = res.result.total;
					this.users = res.result;
					this.listLoading = false;
				});
			},
			//删除
			handleQuery: function (index, row) {
				this.$store.state.studio.name=row.studioname
				this.$store.state.studio.studentsCount=row.studentsCount
				this.$router.push({path: '/studioDetail'})
			},
			//显示编辑
			handleAdd: function () {
				this.userAddVisible = true;
			},
			//显示编辑
			handleEdit: function (idx,row) {
				this.transRow=row
				this.transRow['provinces']=row.province.split(',')
				console.log(this.transRow['provinces'])
				this.userModifyVisible = true;
			},
			handleStates:function (idx,row){
				this.transRow=row
				this.transRow['provinces']=row.province.split(',')
				this.transRow.enable=!this.transRow.enable
				user_info_update(this.transRow).then((res)=>{
					console.log(res)
				})

			},
			selsChange: function (sels) {
				this.sels = sels;
			},
		},
		mounted() {
			axios.defaults.headers.common["Art-Token"] = sessionStorage.getItem('Art-Token');
			getStudioList().then((res)=>{this.studios=res})
			this.exampaper=this.$store.state.exampaper
			this.getUsers();
		}
	}

</script>

<style>
.el-button--small{
	padding: 1px 1px;
}
.el-dialog__header{
	text-align: center;
}
.el-dialog__title{
	font-size: 32px;
}
</style>